package com.goldze.mvvmhabit.ui.expandswipe;

import android.app.Application;

import androidx.annotation.NonNull;
import androidx.databinding.ObservableArrayList;
import androidx.databinding.ObservableField;
import androidx.databinding.ObservableList;

import com.goldze.mvvmhabit.BR;
import com.goldze.mvvmhabit.R;
import com.goldze.mvvmhabit.widght.expandswipe.ExpandSwipeItemBind;
import com.goldze.mvvmhabit.widght.expandswipe.ExpandSwipeItemBinding;
import com.goldze.mvvmhabit.widght.expandswipe.ExpandSwipeViewModel;

import me.goldze.mvvmhabit.base.BaseViewModel;

public class ExpandSwipeRvViewModel extends BaseViewModel {
    public ObservableField<String> rightTitleLabel = new ObservableField<>("");
    public ObservableField<Boolean> showEmptyViewtest = new ObservableField<>(false);
    public ObservableList<ExpandSwipeViewModel> list = new ObservableArrayList<>();

    public void initData(){
        list.clear();
        for (int i = 0; i < 5; i++) {
//            KLog.e("sss  "+i);
            ExpandSwipeParentViewModel parentViewModel = new ExpandSwipeParentViewModel(i,"这是第"+(i+1)+"条数据");
            parentViewModel.initData();
            list.add(parentViewModel);
        }
    }
    public ExpandSwipeItemBinding<ExpandSwipeParentViewModel> parentBinding = ExpandSwipeItemBinding.of(new ExpandSwipeItemBind<ExpandSwipeParentViewModel>() {
        @Override
        public void setItemBind(ExpandSwipeItemBinding itemBind, int parentPosition, ExpandSwipeParentViewModel item) {
            itemBind.set(BR.viewModel, R.layout.item_expand_swpie_parent);
        }

        @Override
        public void setItemBind(ExpandSwipeItemBinding itemBind, int parentPosition, int childPosition, ExpandSwipeParentViewModel item) {
        }
    });

    public ExpandSwipeItemBinding<ExpandSwipeChildViewModel> childBinding =  ExpandSwipeItemBinding.of(new ExpandSwipeItemBind<ExpandSwipeChildViewModel>() {
        @Override
        public void setItemBind(ExpandSwipeItemBinding itemBind, int parentPosition, ExpandSwipeChildViewModel item) {
            itemBind.set(BR.viewModel,R.layout.item_expand_swipe_child);
        }

        @Override
        public void setItemBind(ExpandSwipeItemBinding itemBind, int parentPosition, int childPosition, ExpandSwipeChildViewModel item) {
        }
    });


    public ExpandSwipeRvViewModel(@NonNull Application application) {
        super(application);
    }
}
